package com.br3akr.rollerServer.engine;

import java.io.IOException;
import java.net.ServerSocket;


public class Server {

	private static Room room;

    public static void main(String[] args) throws IOException {
		System.out.println("Starting the server...");
        ServerSocket serverSocket = null;
        boolean listening = true;
		System.out.println("Initializing the Room...");
        room = new Room();

        try {
			System.out.println("Preparing to listen to socket 4444");
            serverSocket = new ServerSocket(4444);
			System.out.println("Server is UP!");
        } catch (IOException e) {
            System.err.println("Could not listen on port: 4444.");
            System.exit(-1);
        }

        while (listening)
        	new ServerThread(serverSocket.accept()).start();

        serverSocket.close();
    }
	
	public static Room getRoom() {
		return room;
	}
}